<!-- 表单弹窗 -->
<form id="user-form" lay-filter="user-form" class="layui-form layui-form-pane" style="padding: 15px 15px 0px 15px">
    <input name="pid" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="layui-icon required">&#xe642;</i>登录账号</label>
        <div class="layui-input-block">
            <input name="loginName" placeholder="请输入登录账号　(默认密码：ahebai100)" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><i class="layui-icon required">&#xe642;</i>用户名称</label>
        <div class="layui-input-block">
            <input name="userName" placeholder="请输入用户名称" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" required/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input name="mobileNo" placeholder="请输入手机号码" type="text" class="layui-input" lay-verify="required|phone"
                   required/>
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label"><i class="layui-icon required">&#xe642;</i>是否启用</label>
        <div class="layui-input-block">
            <input type="radio" name="isEnable" value="1" title="是" checked/>
            <input type="radio" name="isEnable" value="0" title="否"/>
        </div>
    </div>
    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog"><i class="layui-icon">&#x1006;</i> 取消</button>
        <button class="layui-btn" lay-filter="user-form-submit" lay-submit><i class="layui-icon">&#xe605;</i> 保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'jquery', 'sadmin', 'form'], function () {
        var $ = layui.$ //重点处
        var layer = layui.layer;
        var sadmin = layui.sadmin;
        var form = layui.form;

        form.render('radio');

        var url = 'system/user/save';
        // 回显user数据
        var user = sadmin.getTempData('system_user');
        if (user) {
            $('input[name="loginName"]').attr('readonly', 'readonly');
            url = 'system/user/save';
            form.val('user-form', user);
        }

        // 表单提交事件
        form.on('submit(user-form-submit)', function (data) {
            layer.load(2);
            $.post(url, data.field, function (result) {
                layer.closeAll('loading');
                layer.msg(result.msg);
                sadmin.finishPopupCenter();
            });
            return false;
        });
    });
</script>